package com.test2015.Swing.gridpanel;

import java.awt.Color;
import java.awt.Container;
import java.awt.Graphics;

import javax.swing.JFrame;
import javax.swing.JPanel;

public class GridPanelTest extends JFrame{
	
	private Color lightColor = new  Color(154,246,123);
	
	public GridPanelTest(){
		GridPanel gridPanel = new GridPanel(500,500,50);
		Container pane = this.getContentPane();
		
		pane.setLayout(null);
		pane.add(gridPanel);
		gridPanel.setSize(gridPanel.getPreferredSize());
		gridPanel.setLocation(50, 8);
		pane.setBackground(new Color(190,196,205));
		
		gridPanel.setLayout(null);
		
		int lenOfSide = gridPanel.getLenOfSide()-2;
		OvalPanel ovalPanel = new OvalPanel(lenOfSide, lightColor);
		gridPanel.add(ovalPanel);
		ovalPanel.setBounds(51, 101, lenOfSide, lenOfSide);
		
		this.setDefaultCloseOperation(EXIT_ON_CLOSE);
		this.setSize(600	,550);
		this.setLocationRelativeTo(null);
		this.setVisible(true);
	}
	
	public static void main(String[] args) {
		new GridPanelTest();
	}
	
}

class OvalPanel extends JPanel{
	private int diameter = 0;
	private Color backGround = Color.black;
	
	public OvalPanel(int radius,Color c){
		this.diameter = radius;
		this.backGround = c;
	}
	
	@Override
	protected void paintComponent(Graphics g) {
		g.setColor(backGround);
		g.fillOval(0, 0,diameter ,diameter);
	}
} 